package com.ruoyi.develop.goodsSaleTowork.service.impl;

import java.util.List;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.DateUtils;
        import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.ruoyi.develop.goodsSaleTowork.mapper.GoodsSaleToworkMapper;
import com.ruoyi.develop.goodsSaleTowork.domain.GoodsSaleTowork;
import com.ruoyi.develop.goodsSaleTowork.service.IGoodsSaleToworkService;

/**
 * 派工产品Service业务层处理
 * @author qh
 * @date 2025-04-09
 */
@Service
public class GoodsSaleToworkServiceImpl implements IGoodsSaleToworkService {
    @Resource
    private GoodsSaleToworkMapper goodsSaleToworkMapper;

    /**
     * 查询派工产品
     * @param id 派工产品主键
     * @return 派工产品
     */
    @Override
    public GoodsSaleTowork selectById(String id) {
        return goodsSaleToworkMapper.selectById(id);
    }

    /**
     * 查询派工产品列表
     * @param entity 派工产品
     * @return 派工产品
     */
    @Override
    public List<GoodsSaleTowork> selectList(GoodsSaleTowork entity) {
        return goodsSaleToworkMapper.selectList(entity);
    }

    /**
     * 新增派工产品
     * @param entity 派工产品
     * @return 结果
     */
    @Override
    public int insert(GoodsSaleTowork entity) {
        if(StringUtils.isBlank(entity.getId())){
            entity.setId(IdUtils.fastSimpleUUID());
        }
                entity.setCreateBy(SecurityUtils.getUsername());
                entity.setCreateTime(DateUtils.getNowDate());
            return goodsSaleToworkMapper.insert(entity);
    }

    /**
     * 修改派工产品
     * @param entity 派工产品
     * @return 结果
     */
    @Override
    public int update(GoodsSaleTowork entity) {
                entity.setUpdateBy(SecurityUtils.getUsername());
                entity.setUpdateTime(DateUtils.getNowDate());
        return goodsSaleToworkMapper.update(entity);
    }

    /**
     * 批量删除派工产品
     * @param ids 需要删除的派工产品主键
     * @return 结果
     */
    @Override
    public int deleteByIds(String[] ids) {
        return goodsSaleToworkMapper.deleteByIds(ids);
    }

    /**
     * 删除派工产品信息
     * @param id 派工产品主键
     * @return 结果
     */
    @Override
    public int deleteById(String id) {
        return goodsSaleToworkMapper.deleteById(id);
    }
}
